<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>while_mplexing (ChainETL)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre><span class="ruby-comment cmt"># File etl/std.rb, line 240</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">while_mplexing</span>(<span class="ruby-identifier">ctx</span>, <span class="ruby-identifier">block</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">code</span>)

    <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">is_savepoint?</span>(<span class="ruby-identifier">block</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">is_chain?</span>(<span class="ruby-identifier">block</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">is_mplex?</span>(<span class="ruby-identifier">ctx</span>[<span class="ruby-identifier">:dto</span>])
      <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">ctx</span>[<span class="ruby-identifier">:dto</span>].<span class="ruby-identifier">cur</span>
        <span class="ruby-comment cmt"># de-mux</span>
        <span class="ruby-identifier">mplex_dto</span> = <span class="ruby-identifier">ctx</span>[<span class="ruby-identifier">:dto</span>]
        <span class="ruby-identifier">ctx</span>[<span class="ruby-identifier">:dto</span>] = <span class="ruby-identifier">mplex_dto</span>.<span class="ruby-identifier">cur</span>

        <span class="ruby-identifier">while_mplexing</span>(<span class="ruby-identifier">ctx</span>, <span class="ruby-identifier">block</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">code</span>) <span class="ruby-comment cmt"># recursive call</span>

        <span class="ruby-comment cmt"># re-mux</span>
        <span class="ruby-identifier">mplex_dto</span>.<span class="ruby-identifier">increment_exec</span>(<span class="ruby-identifier">ctx</span>[<span class="ruby-identifier">:dto</span>])
        <span class="ruby-identifier">ctx</span>[<span class="ruby-identifier">:dto</span>] = <span class="ruby-identifier">mplex_dto</span>        
      <span class="ruby-keyword kw">end</span>
      <span class="ruby-identifier">ctx</span>[<span class="ruby-identifier">:dto</span>].<span class="ruby-identifier">reset_exec</span>
    <span class="ruby-keyword kw">else</span>
      <span class="ruby-comment cmt"># invoke the code: we're out of multiplexed DTOs, or we're dealing with savepoints or chains</span>
      <span class="ruby-comment cmt"># (only the innermost chain performs the actual demultiplexing)</span>
      <span class="ruby-keyword kw">yield</span> 
    <span class="ruby-keyword kw">end</span>    
  <span class="ruby-keyword kw">end</span></pre>
</body>
</html>